﻿using LPY.LeHealth.DAL;
using LPY.LeHealth.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LPY.LeHealth.Service
{
    using AutoMapper;
    using AutoMapper.Execution;
    using AutoMapper.Configuration;
    using AutoMapper.Mappers;
    using LPY.LeHealth.DTO;
   public class ComboService
    {
       private ComboDAL dal;
       private ZuheComboDAL zuhedal;
       private Combo_TypeDAL typeDal;
       public ComboService()
        {
            dal = new ComboDAL();
            typeDal = new Combo_TypeDAL();
            zuhedal = new ZuheComboDAL();
        }
       /// <summary>
       /// 根据适用人群显示
       /// </summary>
       /// <param name="Appropriate"></param>
       /// <returns></returns>
       public List<Combo> GetCombo()
       {
           var hospital = dal.GetCombo();
           var rtv = Mapper.Map<List<ComboDTO>, List<Combo>>(hospital);
           return rtv;
       }
       /// <summary>
       /// 根据价格 性别 类别搜索
       /// </summary>
       /// <param name="Price"></param>
       /// <param name="sex"></param>
       /// <param name="TypeId"></param>
       /// <returns></returns>
       public List<Combo> GetComboS(Decimal Price, int sex, int TypeId)
       {
           var hospital = dal.GetComboS(Price, sex, TypeId);
           var rtv = Mapper.Map<List<ComboDTO>, List<Combo>>(hospital);
           return rtv;
       }


       /// <summary>
       /// 根据类型获取体检套餐列表
       /// </summary>
       /// <param name="typeId"></param>
       /// <returns></returns>
       public List<Combo> GetComboByType(int typeId)
       {
           var hospital=dal.GetComboByType(typeId);
               var rtv =Mapper.Map<List<ComboDTO>,List<Combo>>(hospital);
               return rtv;
           
       }


       /// <summary>
       ///根据体检套餐类型名称，获取体检套餐类型id
       /// </summary>
       /// <param name="combo_type"></param>
       /// <returns></returns>
       public int getComboTypeIdByName(string combo_type)
       {
           var hospital = typeDal.getComboTypeIdByName(combo_type);
           var rtv = Mapper.Map<int>(hospital);
           return rtv;
       }


       /// <summary>
       ///获取全部体检套餐类型
       /// </summary>
       /// <param name="combo_type"></param>
       /// <returns></returns>
       public List<ComboTypeDTO> getComboType()
       {
           var hospital = typeDal.getComboType();
           var rtv = Mapper.Map<List< ComboTypeDTO>>(hospital);
           return rtv;
       }
        /// <summary>
      /// 根据地区ID获取体检套餐列表
      /// </summary>
      /// <param name="areaId"></param>
      /// <returns></returns>
       public List<combo2> GetComboByArea(int areaId)
       {
           return dal.GetComboByArea(areaId);
       }


        /// <summary>
      /// 根据地区ID获取体检套餐列表的数目
      /// </summary>
      /// <param name="areaId"></param>
      /// <returns></returns>
       public int GetComboByAreaCount(int areaId)
       {
           return dal.GetComboByAreaCount(areaId);
       }

       /// <summary>
        /// 显示前1条组合套餐数据
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
       public List<ZuhetoCombo> GetZuhe()
       {
           return zuhedal.GetZuhe(1);
       }

       /// <summary>
       /// 按热门套餐价格排序全部
       /// </summary>
       /// <returns></returns>
       public List<ComboDTO> getprice(int eid)
       {
           var hospital = new ComboDAL().GetAllComboType2(eid);
           var rtv = Mapper.Map<List<ComboDTO>, List<ComboDTO>>(hospital);
           return rtv;
       }
        /// <summary>
       /// 按热门套餐价格排序前N条
       /// </summary>
       /// <returns></returns>
       public List<ComboDTO> getNprice(int eid)
       {
           var hospital = new ComboDAL().GetAllComboType2N(eid);
           var rtv = Mapper.Map<List<ComboDTO>, List<ComboDTO>>(hospital);
           return rtv;

       }
       
       /// <summary>
       /// 按热门套餐销量排序全部
       /// </summary>
       /// <returns></returns>
       public List<ComboDTO> getsal(int eid)
       {
           var hospital = new ComboDAL().GetAllComboType3(eid);
           var rtv = Mapper.Map<List<ComboDTO>, List<ComboDTO>>(hospital);
           return rtv;
       }
        /// <summary>
       /// 按热门套餐销量排序全部
       /// </summary>
       /// <returns></returns>
       public List<ComboDTO> Ngetsal(int eid)
       {
           var hospital = new ComboDAL().GetAllComboType3N(eid);
           var rtv = Mapper.Map<List<ComboDTO>, List<ComboDTO>>(hospital);
           return rtv;
       }
       
       /// <summary>
       /// 按热门套餐ID显示
       /// </summary>
       /// <returns></returns>
       public List<ComboDTO> GetId(int eid)
       {
           var hospital = new ComboDAL().GetAllComboType4(eid);
           var rtv = Mapper.Map<List<ComboDTO>, List<ComboDTO>>(hospital);
           return rtv; 
       }
       /// <summary>
       /// 按热门套餐ID家加载全部
       /// </summary>
       /// <returns></returns>
       public List<ComboDTO> GetIdAll(int eid)
       {

           var hospital = new ComboDAL().GetAllComboType5(eid);
           var rtv = Mapper.Map<List<ComboDTO>, List<ComboDTO>>(hospital);
           return rtv;
       }
    }
}
